const Express = require('express')
const Bodyparser = require('body-parser')
const Hbs = require('hbs')
const Path = require('path')

//---------------- webserver -------------------------//
const port = 3000

var service = Express()
service.disable('etag')

///---------- body parser ----------///
service.use(Bodyparser.urlencoded({ extended: false }))
service.use(Bodyparser.json())
//service.use(Bodyparser())

///---------- hbs html template setting--------------///
let suffix = 'html'
service.set('view engine', suffix)
service.engine(suffix, Hbs.__express)

///---------- resource -------------///
service.use('/resource', Express.static('public'))

///--------- api ------------------ ///
const api_router = require('./api')
service.use('/api', api_router)

///--------- admin ----------------///
const admin_router = require('./admin')
service.use('/admin', admin_router)

service.listen(port, ()=>{
    console.log(`Service listening on port ${port}`)
})
